<?php

namespace App\Admin\Repositories;

use App\Models\Divination\Answer;
use App\Models\Divination\Divination as Model;
use Dcat\Admin\Repositories\EloquentRepository;

class Divination extends EloquentRepository
{
    /**
     * Model.
     *
     * @var string
     */
    protected $eloquentClass = Model::class;

    public function render($id)
    {
        // 获取ID
        $data = Answer::where('div_id', $id)->with('user')
            ->get(['user.name', 'answer', 'amount', 'created_at'])
            ->toArray();

        $titles = [
            '老师',
            '回答内容',
            '奖励',
            '时间',
        ];

        return Table::make($titles, $data);
    }


}
